package com.centit.framework.ip.oa.service.impl;

import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.centit.framework.ip.oa.service.UserBindManager;
import com.centit.support.database.utils.PageDesc;

import com.centit.framework.jdbc.service.BaseEntityManagerImpl;


import com.centit.framework.ip.oa.po.UserBind;
import com.centit.framework.ip.oa.dao.UserBindDao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;

/**
 * UserBind  Service.
 * create by scaffold 2018-10-09
 *
 * @author codefan@sina.com
 *         用户绑定表用户绑定表，用于与投管系统的用户绑定
 */
@Service
public class UserBindManagerImpl
        extends BaseEntityManagerImpl<UserBind, java.lang.String, UserBindDao>
        implements UserBindManager {

    public static final Log log = LogFactory.getLog(UserBindManager.class);


    private UserBindDao userBindDao;

    @Resource(name = "userBindDao")
    @NotNull
    public void setUserBindDao(UserBindDao baseDao) {
        this.userBindDao = baseDao;
        setBaseDao(this.userBindDao);
    }

    /*
         @PostConstruct
        public void init() {

        }

     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public JSONArray listUserBindsAsJson(
            String[] fields,
            Map<String, Object> filterMap, PageDesc pageDesc) {

        return null;
    }

    public void updateTokenToUser(String userCode,String token){
        userBindDao.updateTokenToUser(userCode,token);
    }

    public UserBind getUserByTzUserId(String tzUserId){
        return userBindDao.getUserByTzUserId(tzUserId);
    }

    public UserBind getUserByUserCode(String userCode){
        return userBindDao.getUserByUserCode(userCode);
    }
}

